New-NetFirewallRule -DisplayName "Block_TCP_135_Internet" `
-Direction Inbound -Protocol TCP -LocalPort 135 -Action Block
New-NetFirewallRule -DisplayName "Block_TCP_1-442_Internet" `
-Direction Inbound `
-Protocol TCP `
-LocalPort 1-442 `
-Action Block `
-Enabled True
|
New-NetFirewallRule -DisplayName "Block_TCP_CustomRanges" `
-Direction Inbound `
-Protocol TCP `
-LocalPort 1-442,444-3388,3390-64535 `
-Action Block `
-Enabled True
|
# Список разрешённых IP
$AllowedIPs = "121.172.72.4","223.27.72.4"
foreach ($ip in $AllowedIPs) {
New-NetFirewallRule -DisplayName "Allow_RDP_$ip" `
-Direction Inbound `
-Protocol TCP `
-LocalPort 3389 `
-RemoteAddress $ip `
-Action Allow `
-Enabled True `
-InterfaceAlias "WAN"
}
|
Get-NetIPAddress | Select-Object InterfaceAlias, IPv4Address, PrefixLength
New-NetFirewallRule -DisplayName "Allow TCP Port 3000" -Direction Inbound -Protocol TCP -LocalPort 3000 -Action Allow
Get-NetFirewallRule | Where-Object {
($_ | Get-NetFirewallPortFilter | Where-Object {
$_.LocalPort -eq 3000 -and $_.Protocol -eq "TCP"
})}
|
Например, если ищете правила с «3000» в названии:
Get-NetFirewallRule | Where-Object DisplayName -like "*3000*"
Get-NetFirewallRule -DisplayName "Allow TCP Port 3000" | Get-NetFirewallPortFilter
Get-NetFirewallRule | Select-Object DisplayName